package com.whmnx.main.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.classic.adapter.BaseAdapterHelper;
import com.classic.adapter.CommonRecyclerAdapter;
import com.whmnx.base.bean.PingTanBean;
import com.whmnx.base.utils.CodeTimeUtils;
import com.whmnx.base.utils.ImageUtil;
import com.whmnx.base.utils.TimeUtils;
import com.whmnx.main.R;
import com.whmnx.main.ui.fragment.CanTeamDetailsFragment;

/**
 * author : huang
 * date   : 2020/10/19 0019 9:17
 * version: 1.0
 * @author Administrator
 */
public class PineTanAdapter extends CommonRecyclerAdapter<PingTanBean> {
    private  Context context;
    public PineTanAdapter(Context context) {
        super(context, R.layout.item_open_team2);
        this.context = context;
    }


    @Override
    public void onUpdate(BaseAdapterHelper helper, PingTanBean item, int position) {
        helper.setText(R.id.tv, "还差" + item.getGlang() + "人成团");
        ImageUtil.setImage(helper.getView(R.id.iv), item.getGroupUserModel().get(0).getUserInfo_Image());

        CodeTimeUtils.payOrderTime(helper.getView(R.id.tv_time), TimeUtils.string2Millis(item.getGDateTime()), () -> {
            helper.setText(R.id.tv_time,"已过期");
            helper.setVisible(R.id.tv_time, View.INVISIBLE);
        });

        helper.getView(R.id.tv_ping).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(context,CanTeamDetailsFragment.class).putExtra("item", item));
            }
        });
    }
}
